package com.stable.actor.remotedemo;

import java.io.Serializable;

/**
 * 创建订单命令
 */
@lombok.Data
@lombok.NoArgsConstructor
@lombok.AllArgsConstructor
class CreateOrderCommand implements Serializable {
    private  Order order;

    public Order getOrder() { return order; }

    @Override
    public String toString() {
        return "CreateOrderCommand{" + order + "}";
    }
}

/**
 * 订单类
 */
class Order implements Serializable{
    private final String orderId;
    private final String userId;
    private final String productName;
    private final int quantity;
    private final double amount;

    public Order() {
        this(null, null, null, 0, 0.0);
    }
    public Order(String orderId, String userId, String productName, int quantity, double amount) {
        this.orderId = orderId;
        this.userId = userId;
        this.productName = productName;
        this.quantity = quantity;
        this.amount = amount;
    }

    // getters
    public String getOrderId() { return orderId; }
    public String getUserId() { return userId; }
    public String getProductName() { return productName; }
    public int getQuantity() { return quantity; }
    public double getAmount() { return amount; }

    @Override
    public String toString() {
        return String.format("Order[%s, user=%s, product=%s, qty=%d, amount=%.2f]",
                orderId, userId, productName, quantity, amount);
    }
}

/**
 * 支付请求
 */
class PaymentRequest {
    private final String orderId;
    private final String userId;
    private final double amount;

    public PaymentRequest(String orderId, String userId, double amount) {
        this.orderId = orderId;
        this.userId = userId;
        this.amount = amount;
    }

    public String getOrderId() { return orderId; }
    public String getUserId() { return userId; }
    public double getAmount() { return amount; }

    @Override
    public String toString() {
        return String.format("PaymentRequest[order=%s, user=%s, amount=%.2f]", orderId, userId, amount);
    }
}

/**
 * 库存检查请求
 */
class InventoryCheckRequest {
    private final String orderId;
    private final String productName;
    private final int quantity;

    public InventoryCheckRequest(String orderId, String productName, int quantity) {
        this.orderId = orderId;
        this.productName = productName;
        this.quantity = quantity;
    }

    public String getOrderId() { return orderId; }
    public String getProductName() { return productName; }
    public int getQuantity() { return quantity; }

    @Override
    public String toString() {
        return String.format("InventoryCheckRequest[order=%s, product=%s, qty=%d]", orderId, productName, quantity);
    }
}

/**
 * 通知请求
 */
class NotificationRequest {
    private final String userId;
    private final String message;

    public NotificationRequest(String userId, String message) {
        this.userId = userId;
        this.message = message;
    }

    public String getUserId() { return userId; }
    public String getMessage() { return message; }

    @Override
    public String toString() {
        return String.format("NotificationRequest[user=%s, message=%s]", userId, message);
    }
}

